package com.asiainfo.iam.controller;


import com.asiainfo.iam.service.SignatureVerificationService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;

import java.sql.Connection;
import java.util.List;


/**
 * 签名和验签
 */
@RestController
public class SignatureVerificationController {
    private static final Logger log = LoggerFactory.getLogger(SignatureVerificationController.class);

    @Autowired
    private SignatureVerificationService signatureVerificationService;




    /**
     * 对数据进行签名操作，将签名结果更新回数据库。
     * @param databaseName 数据库名称
     * @param tableName 表名称
     * @param connection 数据库连接
     * @param findNameList 查询字段列表
     * @param columnNameList 需要签名的字段列表
     */
    public void signature(String databaseName, String tableName, Connection connection, List<String> findNameList, List<String> columnNameList){
        signatureVerificationService.queryTableContentQianMing(databaseName, tableName, connection, findNameList, columnNameList);

    }

    /**
     * 执行前端验签操作，将数据发送至验签服务，并根据结果更新数据库状态。
     * @param databaseName 数据库名称
     * @param tableName 表名称
     * @param connection 数据库连接
     * @param findNameList 查询字段列表
     * @param columnNameList 需要拼接验证的字段列表
     */
    public void verification(String databaseName, String tableName, Connection connection, List<String> findNameList, List<String> columnNameList){
        signatureVerificationService.queryTableContentYanQian(databaseName, tableName, connection, findNameList, columnNameList);
    }
}
